package com.wanhe.callring.module.callring;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.TextView;

import com.wanhe.base.BaseDialogFragment;
import com.wanhe.callring.R;


/**
 * 呼叫服务结果Dialog
 * Created by XieZaiWei on 2017/2/16.
 */

public class CallResultDialog extends BaseDialogFragment implements View.OnClickListener {

	private static final String KEY_MSG = "msg";
	private String mMsg;

	public static CallRingDialog newInstance(String msg) {
		CallRingDialog fragment = new CallRingDialog();
		Bundle bundle = new Bundle();
		bundle.putString(KEY_MSG, msg);
		fragment.setArguments(bundle);
		return fragment;
	}

	@Override
	public void onCreate(@Nullable Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		if (getArguments() != null) {
			mMsg = getArguments().getString(KEY_MSG);
		}
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		getDialog().requestWindowFeature(Window.FEATURE_NO_TITLE);
		mView = inflater.inflate(R.layout.call_result_dialog, container, false);
		return mView;
	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		TextView tv_msg = (TextView) findViewById(R.id.tv_msg);
		tv_msg.setText(mMsg);
		findViewById(R.id.tv_ok).setOnClickListener(this);
	}



	@Override
	public void onClick(View v) {
		int id = v.getId();
		if (id == R.id.tv_ok) {
			dismiss();
		}
	}
}
